
module.exports = function ($scope, $state, $stateParams,$resource,$modal,FileUploader,items,$modalInstance) {  
    console.log(items);
    $scope.employee={};
    // $scope.a={};
    $scope.fieldarr=[
        {name:'环保领域',value:'0'},
        {name:'城市建设领域',value:'1'},
        {name:'农药领域',value:'2'},
    ]
    var para={
        expert_code:items.expert_code
    }
     $resource('/api/ac/ggc/reviewExpertService/findInfo', {}, {}).save(para, function(res){
            // console.log(res);
            if(res.errcode === 0){            
                $scope.a=res.data;
                console.log($scope.a);
            }else{
                alert(res.errmsg);
           
            }
        });

            //正则判断电话号  
            $scope.checkphone=function(x){
                if(!/^1[34578]\d{9}$/.test(x)) return "您输入的电话号长度或格式错误";
            }
			$scope.showphoneinfo=function(x){
                console.log(x);
                if(x==undefined){
                    $scope.employee.phoneinfo="";
                   return;
                  }
                if(x==''){
                    $scope.employee.phoneinfo="";
                   return;
                  }
                                         
            if($scope.checkphone(x)=="您输入的电话号长度或格式错误"){                
                $scope.employee.phoneinfo="您输入的电话号长度或格式错误"
            }else{
                     $scope.employee.phoneinfo="";
                    }
            }

    var uploader = $scope.uploader = new FileUploader({
        url: 'https://dlqt.juyouhx.com/Api/Api/ObjectToOss?topdir=aa&selfdir=bb'
    });

    uploader.filters.push({
        name: 'imageFilter',
        fn: function(item /*{File|FileLikeObject}*/, options) {
            var type = '|' + item.type.slice(item.type.lastIndexOf('/') + 1) + '|';
            return '|jpg|png|jpeg|bmp|gif|'.indexOf(type) !== -1;
        }
    });
    
    
    uploader.onSuccessItem = function(fileItem, response, status, headers) {
        $scope.a.photo = response.savename;
    };


$scope.submit = function(){
    var para = { 
        expert_code:items.expert_code,
        expert_name:$scope.a.expert_name,
        field_type:$scope.a.field_type,
        photo:$scope.a.photo,
        mobile:$scope.a.mobile,
        email:$scope.a.email,
        cardno:$scope.a.cardno,
        profile:$scope.a.profile
     }
    //  if($scope.company_name==undefined||$scope.company_name==''){
    //      alert('请填写单位名称');
    //      return;
    //  }
     console.log(para);
     console.log('参数');
     $resource('/api/ac/ggc/reviewExpertService/create', {}, {}).save(para, function(res){
            // console.log(res);
            if(res.errcode === 0){            
                alert('修改成功');
                $modalInstance.close();
            }else{
                alert(res.errmsg);
           
            }
        });
}

};
